package by.demchenko.sample.services;

import by.demchenko.sample.datamodel.Account;
import by.demchenko.sample.datamodel.Course;
import by.demchenko.sample.datamodel.Person;
import by.demchenko.sample.datamodel.Schedule;

import javax.persistence.PersistenceException;
import javax.transaction.Transactional;
import java.util.Date;
import java.util.List;

public interface UserService {

    @Transactional
    void createNewUser(Person person, Account account) throws PersistenceException;

    @Transactional
    void removeUser(Integer id);

    @Transactional
    void save(Person person);

    @Transactional
    void saveOrUpdate(Person person);

    Person get(Integer id);

    Person get(Integer id, boolean fetchJoins);

    List<Person> findAll();

    boolean enrollInCourse(Person student, Course course, Date date);

    Account getAccountByCredentials(String userName, String password);

    boolean isEnrolledInCourse(Person user, Course course, Date startDate);

    boolean cancelCourse(Person student, Schedule schedule);
}